//package configuration;
//
//import lombok.extern.slf4j.Slf4j;
//import org.junit.jupiter.api.Test;
//import sun.misc.URLClassPath;
//import sun.security.tools.KeyStoreUtil;
//
//import java.io.File;
//import java.io.IOException;
//import java.io.InputStream;
//import java.io.OutputStream;
//import java.net.URISyntaxException;
//import java.net.URL;
//import java.nio.file.Files;
//import java.nio.file.Path;
//import java.nio.file.Paths;
//import java.nio.file.StandardOpenOption;
//import java.security.KeyStore;
//import java.security.KeyStoreException;
//import java.security.NoSuchAlgorithmException;
//import java.security.cert.CertificateException;
//import java.util.Date;
//import java.util.Enumeration;
//@Slf4j
//public class SSLConfig {
//    static String pwd= "secrets";
//    @Test
//    public void createNewFile(String filename) throws URISyntaxException, IOException {
//        URL url = URLClassPath.pathToURLs(filename)[0];
//        Path path = Paths.get(url.toURI());
//        File file = path.toFile();
//        if(!file.exists()){
//            file.createNewFile();
//        }
//    }
//    @Test
//    public void CustomGenerateCacerts() throws Exception {
//
//        String filename= "clientkeystore";
//        URL url = URLClassPath.pathToURLs(filename)[0];
//        KeyStore jks = KeyStore.getInstance("jks");
//        InputStream inputStream = Files.newInputStream(Paths.get(url.toURI()), StandardOpenOption.READ);
//        jks.load(inputStream,"javacaps".toCharArray());
//        Enumeration<String> aliases = jks.aliases();
//        while (aliases.hasMoreElements()){
//            String alias = aliases.nextElement();
//            Date creationDate = jks.getCreationDate(alias);
//            log.info("{},{}",alias,creationDate);
//        }
//
//    }
//    @Test
//    public void generateCacerts() throws Exception {
//        // F:\integration\basic\SpringWithGradle-gitee\Spring-Boot-all\Mvc\src\test\java
//        URL url = URLClassPath.pathToURLs("test.jks")[0];
//        OutputStream outputStream = Files.newOutputStream(Paths.get(url.toURI()));
//        KeyStore cacertsKeyStore = KeyStoreUtil.getCacertsKeyStore();
//        cacertsKeyStore.store(outputStream,pwd.toCharArray());
//
//    }
//    @Test
//    public void verify() throws KeyStoreException, URISyntaxException, IOException, CertificateException, NoSuchAlgorithmException {
//        KeyStore jks = KeyStore.getInstance("jks");
//        URL url = URLClassPath.pathToURLs("test.jks")[0];
//        InputStream inputStream = Files.newInputStream(Paths.get(url.toURI()), StandardOpenOption.READ);
//        org.apache.tomcat.util.security.KeyStoreUtil.load(jks,inputStream,pwd.toCharArray() );
//        Enumeration<String> aliases = jks.aliases();
//        while (aliases.hasMoreElements()){
//            String alias = aliases.nextElement();
//            Date creationDate = jks.getCreationDate(alias);
//            log.info("{},{}",alias,creationDate);
//        }
//
//
//
//    }
//}
